package com.example.citypolitics.controller;

import com.alibaba.fastjson.JSON;
import com.example.citypolitics.util.GatewayRequestUtil;
import com.example.citypolitics.model.GatewayResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/yida")
public class YIDAController {

    /**
     * 请求接口地址
     */
    public static final String SEARCH_FORM_DATAS = "/yida_vpc/form/searchFormDatas.json";

    @GetMapping("/hello")
    public String hello() {

        GatewayResult result = null;
        try {
            Map<String, String> param = new HashMap<String, String>();
            param.put("pageSize", "10");
            param.put("currentPage", "1");
            param.put("appType", "APP_XXX");
            param.put("systemToken", "");
            param.put("userId", "yida_pub_account");
            param.put("formUuid", "FORM-XXX");

            result = GatewayRequestUtil.baseRequest(param, SEARCH_FORM_DATAS);

            System.out.println(result);

            return JSON.toJSONString(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "error";
    }
}
